home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Online / SpeakFreely / src / lpc10 / mload.c < prev    next >
C/C++ Source or Header  |  2000-05-18  |  1KB  |  61 lines

  1. /******************************************************************
  2. *
  3. *    MLOAD Version 48
  4. *
  5. ******************************************************************
  6. *
  7. *  Load a covariance matrix
  8. *
  9. *  Inputs:
  10. *    ORDER            - Analysis order
  11. *    AWINS            - Analysis window start
  12. *    AWINF            - Analysis window finish
  13. *    SPEECH(AWINF)    - Speech buffer
  14. *  Outputs:
  15. *    PHI(ORDER,ORDER) - Covariance matrix
  16. *    PSI(ORDER)       - Prediction vector
  17. */
  18.  
  19. #include "lpcdefs.h"
  20.  
  21. mload(awinf, speech, phi, psi )
  22. int awinf;
  23. float speech[], phi[ORDER][ORDER], psi[];  
  24. {
  25. int r, c, i, start;
  26.  
  27.  
  28. /*   Load first column of triangular covariance matrix PHI    */
  29.  
  30. start = 1 + ORDER;
  31. for(r=1;r<=ORDER;r++)    {
  32.     phi[r-1][0] = 0.;
  33.     for(i=start;i<=awinf;i++)  {
  34.         phi[r-1][0] += speech[i-1]*speech[i-r];
  35.     }
  36. }
  37.  
  38. /*   Load last element of vector PSI    */
  39.  
  40. psi[ORDER] = 0.;
  41. for(i=start;i<=awinf;i++)
  42.     psi[ORDER] += speech[i]*speech[i-ORDER];
  43.     
  44.  
  45. /*   End correct to get additional columns of PHI    */
  46.  
  47. for(r=2;r<=ORDER;r++)
  48.     for(c=2;c<=r;c++)
  49.         phi[r-1][c-1] = phi[r-2][c-2]
  50.                        - speech[awinf+1-r]*speech[awinf+1-c]
  51.                          + speech[start-r]*speech[start-c];
  52.                                 
  53. /*   End correct to get additional elements of PSI    */
  54.  
  55. for(c=1;c<ORDER;c++)
  56.     psi[c] = phi[c][0] - speech[start-1]*speech[start-1-c]
  57.                                + speech[awinf]*speech[awinf-c];
  58.                                         
  59.  
  60. }
  61.